//
//  HHEditorViewController.m
//  Flower
//
//  Created by 花花 on 2016/12/23.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHEditorViewController.h"

@interface HHEditorViewController ()
@property(nonatomic, strong) UITextField *addressTextF;
@property(nonatomic, strong) UITextField *phoneTextF;
@end

@implementation HHEditorViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.title = @"编辑联系人";
    
    [self setupNav];
    [self createTextField];
}
-(void)setupNav{
    
    self.navigationItem.rightBarButtonItem =[UIBarButtonItem itemWithImage:@"ok" highImage:@"ok" target:self action:@selector(okOnClick)];
    
}

-(void)okOnClick{
    
    if ([self.delegate respondsToSelector:@selector(editorTextF:phoneTextF:)]) {
        [self.delegate editorTextF:self.addressTextF phoneTextF:self.phoneTextF];
    }
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)createTextField{
    
    self.addressTextF = [self addframe:CGRectMake(10, 100, screen_width-20, 30)];
    
    self.addressTextF.text = self.name;
    
    self.phoneTextF = [self addframe:CGRectMake(10, 150, screen_width-20, 30)];
    self.phoneTextF.text = self.phone;
}

-(UITextField *)addframe:(CGRect)frame{
    
    UITextField *textF =[[UITextField alloc]initWithFrame:frame];
    textF.backgroundColor =[UIColor orangeColor];
    [self.view addSubview:textF];
    
    return textF;
}

@end
